package com.qinggeng.project.system.mapper;

import com.qinggeng.project.api.dto.OrdersUserDto;
import com.qinggeng.project.system.domain.OrdersGoods;
import com.qinggeng.project.system.domain.vo.CourierRefundOrdersVO;
import com.qinggeng.project.system.domain.vo.OrdersVO;
import com.qinggeng.project.system.dto.PointOrderDTO;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;

/**
 * 订单商品Mapper接口
 *
 * @author qinggeng
 * @date 2020-06-17
 */
public interface OrdersGoodsMapper
{
    /**
     * 查询订单商品
     *
     * @param ordersGoodsId 订单商品ID
     * @return 订单商品
     */
    public OrdersGoods selectOrdersGoodsById(Long ordersGoodsId);

    /**
     * 查询订单商品列表
     *
     * @param ordersGoods 订单商品
     * @return 订单商品集合
     */
    public List<OrdersGoods> selectOrdersGoodsList(OrdersGoods ordersGoods);

    /**
     * 新增订单商品
     *
     * @param ordersGoods 订单商品
     * @return 结果
     */
    public int insertOrdersGoods(OrdersGoods ordersGoods);

    /**
     * 修改订单商品
     *
     * @param ordersGoods 订单商品
     * @return 结果
     */
    public int updateOrdersGoods(OrdersGoods ordersGoods);

    /**
     * 删除订单商品
     *
     * @param ordersGoodsId 订单商品ID
     * @return 结果
     */
    public int deleteOrdersGoodsById(Long ordersGoodsId);

    /**
     * 批量删除订单商品
     *
     * @param ordersGoodsIds 需要删除的数据ID
     * @return 结果
     */
    public int deleteOrdersGoodsByIds(Long[] ordersGoodsIds);

    List<OrdersGoods> selectOrderGoodListByOrdersId(Long orderId);

    List<OrdersGoods> selectOrderGoodListByOrdersIds(@Param("orderIdList") List<Long> orderIdList);

    /**
     * 根据订单ID获取订单提成
     * @param ordersId
     * @return
     */
    BigDecimal getOrdersPercentageByOrdersId(Long ordersId);

    /**
     * 根据订单ID计算订单平均利润率
     * @param ordersId
     * @return
     */
    BigDecimal getOrdersAverageProfitRateByOrdersId(Long ordersId);

    /**
     * 根据商品主类计算购买人数
     * @param mainCategory
     * @return
     */
    Long getBuyUserNumByMainCategory(Long mainCategory);

    /**
     * 根据商品主类计算商品购买数量
     * @param mainCategory
     * @return
     */
    Long getOrdersGoodsNumByMainCategory(Long mainCategory);

    /**
     * 根据商品主类查询下单用户列表
     * @param mainCategory
     * @return
     */
    List<OrdersUserDto> listOrdersUserDto(Long mainCategory);


    int updateSingleItemRefund(@Param("id") Long id
            ,@Param("singleItemRefund") Integer singleItemRefund);
    /**
     * 退款商品
     * @param orderIdList
     * @return
     */
    List<OrdersGoods> selectReturnOrderGoodListByOrdersIds(List<Long> orderIdList);

    boolean updateOrdersGoodsByOrdersId(Long orderGoodsId);


    List<OrdersVO>  listPointOrder(PointOrderDTO dto);

    List<CourierRefundOrdersVO> selectCourierRefundOrdersVOListByCourierId(@Param("courierId") Long courierId,@Param("refundAplStatus") String refundAplStatus);

    int updateRefundAplStatusByordersId(@Param("ordersGoodsId") Long ordersGoodsId,@Param("refundAplStatus") String refundAplStatus);

    int updateByRefundAplDelByordersGoodsId(@Param("ordersGoodsId") Long ordersGoodsId,@Param("refundAplDel") String refundAplDel);
}
